#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QResizeEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //先让Qlabel铺满整个窗口
    QRect window_rect = this->geometry();
    ui->label->setGeometry(window_rect);

    //设置图片
    QPixmap pixmap(":/people.png");
    ui->label->setPixmap(pixmap);
    //设置自动拉伸
    ui->label->setScaledContents(true);
}

void Widget::resizeEvent(QResizeEvent *event)
{
    //获取图片的位置
    QRect rect = ui->label->geometry();
    //改变图片的大小
    ui->label->setGeometry(rect.x(), rect.y(), event->size().width(), event->size().height());
}

Widget::~Widget()
{
    delete ui;
}


